<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta content="width=device-width, initial-scale=1.0" name="viewport">
    <title>首页</title>
    <link href="favicon.ico" rel="shortcut icon">
    <link href="../static/css/bootstrap.min.css" rel="stylesheet" th:href="@{/css/bootstrap.min.css}"/>
    <link href="../static/css/font-awesome.min.css" rel="stylesheet" th:href="@{/css/font-awesome.min.css}"/>
    <link href="../static/css/main/animate.min.css" rel="stylesheet" th:href="@{/css/main/animate.min.css}"/>
    <link href="../static/css/main/style.min862f.css" rel="stylesheet" th:href="@{/css/main/style.min862f.css}"/>
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content">
    <input id="todoList" type="hidden" th:value="${todoList}">
    <input id="noticeList" type="hidden" th:value="${noticeList}">
    <div class="row">
        <div class="col-sm-3 grdb" style="width: 20%">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <span class="label label-danger pull-left">个人待办:</span>
                    <h5></h5>
                </div>
                <div class="ibox-content">
                    <h1 class="no-margins" style="text-align: center">[[${toDoNum}]]</h1>
                    <div class="stat-percent font-bold text-navy">
                    </div>
                    <small></small>
                </div>
            </div>
        </div>

        <div class="col-sm-3 jrxz" style="width: 20%">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <span class="label label-warning pull-left">今日新增:</span>
                    <h5></h5>
                </div>
                <div class="ibox-content">
                    <h1 class="no-margins" style="text-align: center">[[${dayNum}]]</h1>
                    <div class="stat-percent font-bold text-danger">
                    </div>
                    <small></small>
                </div>
            </div>
        </div>
        <div class="col-sm-3 wcl" style="width: 20%">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <span class="label label-info pull-left">日完成率:</span>
                    <h5></h5>
                </div>
                <div class="ibox-content">
                    <h1 class="no-margins" style="text-align: center">[[${daily}]]%</h1>
                    <div class="stat-percent font-bold text-danger">
                    </div>
                    <small></small>
                </div>
            </div>
        </div>
        <div class="col-sm-3 wcl" style="width: 20%">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <span class="label label-info pull-left">周完成率:</span>
                    <h5></h5>
                </div>
                <div class="ibox-content">
                    <h1 class="no-margins" style="text-align: center">[[${weekly}]]%</h1>
                    <div class="stat-percent font-bold text-danger">
                    </div>
                    <small></small>
                </div>
            </div>
        </div>
        <div class="col-sm-3 wcl" style="width: 20%">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <span class="label label-info pull-left">月完成率:</span>
                    <h5></h5>
                </div>
                <div class="ibox-content">
                    <h1 class="no-margins" style="text-align: center">[[${monthly}]]%</h1>
                    <div class="stat-percent font-bold text-danger">
                    </div>
                    <small></small>
                </div>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-sm-6">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>待办事项</h5>
                </div>
                <div class="ibox-content">
                    <table class="table table-hover no-margins">
                        <tbody class="daiban">

                        </tbody>
                    </table>
                </div>
            </div>
        </div>

        <div class="col-sm-6">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>系统公告</h5>
                </div>
                <div class="ibox-content">
                    <table class="table table-hover no-margins">
                        <tbody class="notice">

                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>

</div>
</div>
<script th:src="@{/js/jquery.min.js}"></script>
<script th:src="@{/js/bootstrap.min.js}"></script>
<script th:src="@{/ajax/libs/flot/jquery.flot.js}"></script>

<th:block th:include="include :: sparkline-js"/>
<!-- 全局js -->
<script th:src="@{/js/jquery.min.js}"></script>
<script th:src="@{/js/bootstrap.min.js}"></script>
<script th:src="@{/js/plugins/slimscroll/jquery.slimscroll.min.js}"></script>
<script th:src="@{/js/jquery.contextMenu.min.js}"></script>
<script th:src="@{/ajax/libs/blockUI/jquery.blockUI.js}"></script>
<script th:src="@{/ajax/libs/layer/layer.min.js}"></script>
<script th:src="@{/erp/js/erp-ui.js}"></script>
<script th:src="@{/erp/js/common.js}"></script>
<script th:src="@{/ajax/libs/fullscreen/jquery.fullscreen.js}"></script>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var prefix_notice = ctx + "framework/notice";

    $(function () {
        var todoList = $("#todoList").val();
        todoList = JSON.parse(todoList);
        $(".daiban").html("");
        for (var key in todoList) {
            $(".daiban").append("<tr><td><a onclick='viewBusiness(" + todoList[key].noticeId + ")'>" + todoList[key].noticeTitle + "</a></td></tr>");
        }

        var noticeList = $("#noticeList").val();
        noticeList = JSON.parse(noticeList);
        $(".notice").html("");
        for (var key in noticeList) {
            $(".notice").append("<tr><td><a onclick='viewNotice(" + noticeList[key].noticeId + ")'>" + noticeList[key].noticeTitle + "</a></td></tr>");
        }
    })

    function viewBusiness(noticeId) {
        $.ajax({
            url: prefix_notice + "/list",
            type: 'post',
            dataType: 'json',
            data: {"noticeId": noticeId},
            success: function (result) {
                var noticeType = result.rows[0].noticeType;
                var pageUrl = result.rows[0].pageUrl;
                var businessKey = result.rows[0].businessKey;
                // var url = ctx + pageUrl + "/getById?id=" + businessKey;
                // if (noticeType === "3") {
                //     $.modal.openTab("软件管理", url);
                // } else if (noticeType === "4") {
                //     $.modal.openTab("采购订单评审", url);
                // }
            },
        });
    }

    function viewNotice(noticeId) {
        $.ajax({
            url: prefix_notice + "/list",
            type: 'post',
            dataType: 'json',
            data: {"noticeId": noticeId},
            success: function (result) {
                var noticeTitle = result.rows[0].noticeTitle;
                var url = prefix_notice + '/details/' + noticeId;
                $.modal.openClose(noticeTitle, url);
            },
        });
    }
</script>
</body>
</html>
